/*
*  Copyright 2019-2020 Zheng Jie
*
*  Licensed under the Apache License, Version 2.0 (the "License");
*  you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*  http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
*/
package com.yuecai.modules.yc_user_coupon.domain;

import lombok.Data;
import cn.hutool.core.bean.BeanUtil;
import io.swagger.annotations.ApiModelProperty;
import cn.hutool.core.bean.copier.CopyOptions;
import javax.persistence.*;
import javax.validation.constraints.*;
import java.sql.Timestamp;
import java.math.BigDecimal;
import java.io.Serializable;

/**
* @website https://el-admin.vip
* @description /
* @author dm
* @date 2020-07-21
**/
@Entity
@Data
@Table(name="yc_user_coupon")
public class YcUserCoupon implements Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id")
    @ApiModelProperty(value = "id")
    private Long id;

    @Column(name = "coupon_id",nullable = false)
    @NotNull
    @ApiModelProperty(value = "优惠券id")
    private Long couponId;

    @Column(name = "user_id",nullable = false)
    @NotNull
    @ApiModelProperty(value = "用户id")
    private Long userId;

    @Column(name = "expire_date",nullable = false)
    @NotNull
    @ApiModelProperty(value = "失效时间 时间戳")
    private Timestamp expireDate;

    @Column(name = "coupon_type",nullable = false)
    @NotNull
    @ApiModelProperty(value = "优惠券类型 关联字典表 COUPON_TYPE  1:全品类 2:限品类 3:限品牌")
    private Integer couponType;

    @Column(name = "conditions_id")
    @ApiModelProperty(value = "条件ID coupon_type 为 2 3 时有值")
    private Long conditionsId;

    @Column(name = "condition_type",nullable = false)
    @NotNull
    @ApiModelProperty(value = "条件的类型，0为金额，1为件数")
    private Integer conditionType;

    @Column(name = "conditions",nullable = false)
    @NotNull
    @ApiModelProperty(value = "条件")
    private BigDecimal conditions;

    @Column(name = "discount_type",nullable = false)
    @NotNull
    @ApiModelProperty(value = "优惠的类型，0为金额，1为折扣")
    private Integer discountType;

    @Column(name = "discount",nullable = false)
    @NotNull
    @ApiModelProperty(value = "优惠")
    private BigDecimal discount;

    @Column(name = "is_use",nullable = false)
    @NotNull
    @ApiModelProperty(value = "是否使用0否1是2锁定")
    private Integer isUse;

    @Column(name = "use_time")
    @ApiModelProperty(value = "优惠券使用时间")
    private Timestamp useTime;

    @Column(name = "coupon_way")
    @ApiModelProperty(value = "获取方式1注册赠券 2 物赠券赠送 3主动领取")
    private Integer couponWay;

    @Column(name = "create_time")
    @ApiModelProperty(value = "发放优惠券时间")
    private Timestamp createTime;


    @Column(name = "remarks")
    @ApiModelProperty(value = "备注")
    private String remarks;

    public void copy(YcUserCoupon source){
        BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
    }
}